from django.http import HttpResponse
from django.urls import reverse
# Create your views here.
def test_int_convert(request,id):
    type_str = str(type(id)).replace('<','').replace('>','')
    return HttpResponse(f"测试int convert，ID：{id}，type：{type_str}")

def test_slug_convert(request,slug_text):
    type_str = str(type(slug_text)).replace('<', '').replace('>', '')
    return HttpResponse(f"测试slug convert，slug_text：{slug_text}，type：{type_str}")

def test_uuid_convert(request,uuid_text):
    type_str = str(type(uuid_text)).replace('<', '').replace('>', '')
    return HttpResponse(f"测试uuid convert，uuid_text：{uuid_text}，type：{type_str}")

def test_kwards(request,key_1,key_2):
    return HttpResponse(f"测试kwards，key_1：{key_1}，key_2：{key_2}")


def test_reverse_with_namespace(request):
    full_url = reverse("course_app:course_list")
    print(f"course_app:course_list的完整url是：{full_url}")
    return HttpResponse(f"course_app:course_list的完整url是：{full_url}")

def test_reverse_with_path_variable(request):
    full_url = reverse('path_demo1',kwargs={"id": 123})
    print(f"path_demo1的完整url是：{full_url}")
    return HttpResponse(f"path_demo1的完整url是：{full_url}")

def test_reverse_with_query_parameter(request):
    full_url = reverse('user_search')+"?name=张三"
    print(f"user_search的完整url是：{full_url}")
    return HttpResponse(f"user_search的完整url是：{full_url}")